package com.xinsilu.hospital.controller;

import com.xinsilu.common.ResponseResult;
import com.xinsilu.hospital.entity.AuthsysUser;
import com.xinsilu.hospital.service.IAuthsysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IAuthsysUserService userService;

    @GetMapping("/search")
    public ResponseResult searchUsers(){
        ResponseResult result = new ResponseResult();
        List<AuthsysUser> userList = this.userService.findAll();
        result.setData(userList);
        return result;
    }

    @PutMapping("/update/roles")
    public ResponseResult assignUserRoles(@RequestBody AuthsysUser user){
        ResponseResult result = new ResponseResult();
        this.userService.assignUserRoles(user);
        return result;
    }
}
